<template>
  <div>
    <div id="main" style="height: 300px;width: 400px;"></div>
  </div>

</template>


<script>
import * as echarts from 'echarts';
export default {
  data (){
    return{
      xdata:[], //保存接口返回的x轴坐标数据
      ydata:[]  //保存接口返回的y轴坐标数据
    }
  },
  mounted() {
  },
  methods: {

    },


    //图表方法
    getchart() {
      //获取id并初始化图表
      var chartDom = document.getElementById('main');
      var myChart = echarts.init(chartDom);
      var option;
      option = {
        xAxis: {
          type: 'category',
          data: this.xdata,
        },
        yAxis: {
          type: 'value'
        },
        series: [
          {
            data: [150, 230, 224, 218, 135, 147, 260],
            type: 'line'
          }
        ]
      };
      option && myChart.setOption(option)//通过setOption()方法生成图表
    },
}
</script>
<style scoped>

</style>